define(function(require, exports, module){
	"require:nomunge,exports:nomunge,module:nomunge";
	//异步请求
var wind_async=require('ddf_wind_async');

var dialog=require('component-dialog');
	
var base=require('component-base');
var history = require('component-history');
	
require('component-page');

exports.init=function(m){
	history.addHis(this,arguments);
    window.$ddf_bank = m;
		var htmlStr = "";
		htmlStr += '<div id="content-header">';
		htmlStr += '<div id="breadcrumb"> <a href=javascript:load("'
				+ ddf.index.index_js
				+ '") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href="javascript:void(0)" class="current">银行账户</a></div>';
//		htmlStr += '<h1>银行账户</h1>';
		htmlStr += '</div>    ';
		htmlStr += '<div class="container-fluid">';
//		htmlStr += '<hr/>';

		htmlStr += '<div class="row-fluid">';
		htmlStr += '<div class="span12">';
		htmlStr += '<div id="alert-tips0" ></div>';
		htmlStr += '<div class="widget-box">';
		htmlStr += '<div class="widget-title">';
		htmlStr += '<span class="icon">';
		htmlStr += '<i class="icon-pencil"></i>';
		htmlStr += '</span>';
		htmlStr += '<h5>操作</h5>';
		htmlStr += '</div>      ';
		htmlStr += '<div class="widget-content">';
		htmlStr += '<div class="div-btn" id="buttonBox">';
		htmlStr += ' <button class="btn btn-primary" id="bindBankCard" type="button" onClick="$ddf_bank.openBindBankCard()">绑定银行卡</button>';

		htmlStr += '</div>';
		htmlStr += '</div>';
		htmlStr += '</div> ';
		
		htmlStr += '<div class="widget-box">';
		htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
		htmlStr += '<h5>绑定银行卡列表</h5>';
		htmlStr += '</div>';
		htmlStr += '<div class="widget-content nopadding dataTables_wrapper">';
		htmlStr += '<table class="table table-bordered data-table">';
		htmlStr += '<thead>';
		htmlStr += '<tr>';
		htmlStr += '<th>序号</th>';
		htmlStr += '<th>银行名称</th>';
		htmlStr += '<th>卡号</th>';
		htmlStr += '<th>持卡人姓名</th>';
		htmlStr += '<th>持卡人手机</th>';
		htmlStr += '<th>绑定时间</th>';
		htmlStr += '<th>绑定状态</th>';
		htmlStr += '<th>是否默认结算账户</th>';
		htmlStr += '<th>操作</th>';
		htmlStr += '</tr>';
		htmlStr += '</thead>';
		htmlStr += '<tbody id="queryBankList">';

		htmlStr += '</tbody>';
		htmlStr += '</table>';
		htmlStr += '<div id="footPageDiv0">';

		htmlStr += '</div>';
		htmlStr += '</div>';

		htmlStr += '</div>  ';
		htmlStr += '</div>';
		htmlStr += '</div> ';
		htmlStr += '</div>';
		
		showDiv("content0");

		$("#content0").html(htmlStr);

		base.showLoading();
		getBankList(1,pageSize);
		
	}

	/**
	 * 获取银行列表
	 * 
	 * @param pageNumber
	 * @param shopname
	 * @param mobile
	 * @param agentId
	 */
	function getBankList(pageNumber,pageSize) {
	    if(bingBanFlag){
	    	base.tips("银行卡绑定成功");
	    	bingBanFlag = false;
	    }
		var params = {
				"page.pageNumber" : pageNumber,
				"page.pageSize" : pageSize
		};
		eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.getBankAccountsDetails,params));
			
			getBankDetailCallBack(data);
			
		}))().start();
	}

	/**
	 * 获取商家列表_回调函数
	 */
	function getBankDetailCallBack(data) {
		
		if(data["BINDBANKCARD"]!=true){
			$("#bindBankCard").css("display","css");
		}
		
		
		
		if (data["code"] == 1) {
            
			var htmlStr = "", availAble = "",defaultFlag = "";
            
			for (var i = 0; i < data["sgAccountList"].length; i++) {
                availAble = data["sgAccountList"][i]["isAvailable"] == 1 ?"已绑定":"未绑定";
                defaultFlag = data["sgAccountList"][i]["defaultFlag"] == 1?"是":"否";
                htmlStr += '<tr>';
				htmlStr += '<td>' + getSequence(data["pageNumber"], i + 1)
						+ '</td>';
				htmlStr += '<td>' + data["sgAccountList"][i]["bankName"]+ '</td>';
				htmlStr +='<td>' + data["sgAccountList"][i]["bankNumber"]+'</td>';		
				htmlStr += '<td>'+data["sgAccountList"][i]["accountName"]+'</td>';
				htmlStr += '<td>'+data["sgAccountList"][i]["mobile"]+'</td>';
				htmlStr += '<td>' + data["sgAccountList"][i]["createTime"] + '</td>';
				htmlStr += '<td>' + availAble  + '</td>';
				htmlStr += '<td>'+ defaultFlag +'</td>';

				if(data["sgAccountList"][i]["isAvailable"]==1 && data["sgAccountList"][i]["defaultFlag"]==1){
					htmlStr += '<td>';
					htmlStr += '<img src="../img/again_2.png" title="默认账户" class="cursor_jt" />&nbsp;&nbsp;&nbsp;';
					htmlStr += '<img src="../img/relieve_2.png" title="解除绑定" class="cursor_jt"/>&nbsp;&nbsp;&nbsp;';
					htmlStr += '<img src="../img/binding_2.png" title="重新绑定" class="cursor_jt"/>&nbsp;&nbsp;&nbsp;';
					htmlStr += ' <a href=javascript:$ddf_bank.isDeleteBank("'+data["sgAccountList"][i]["accountId"]+'")>删除</a> ';
					htmlStr += '</td>';
				}else if(data["sgAccountList"][i]["isAvailable"]==1 && data["sgAccountList"][i]["defaultFlag"]!=1){
					htmlStr += '<td>';
					htmlStr += '<img src="../img/again.png" title="默认账户" onclick=$ddf_bank.setdefaultaccount("'+data["sgAccountList"][i]["accountId"]+'","'+data["sgAccountList"][i]["bankNumber"]+'") />&nbsp;&nbsp;&nbsp;';
					htmlStr += '<img src="../img/relieve.png" title="解除绑定" onclick=$ddf_bank.unbindbanks("'+data["sgAccountList"][i]["accountId"]+'","'+data["sgAccountList"][i]["bankNumber"]+'") />&nbsp;&nbsp;&nbsp;';
					htmlStr += '<img src="../img/binding_2.png" title="重新绑定" class="cursor_jt"/> &nbsp;&nbsp;&nbsp;';
					htmlStr += ' <a href=javascript:$ddf_bank.isDeleteBank("'+data["sgAccountList"][i]["accountId"]+'")>删除</a> ';
					htmlStr += '</td>';
				}else if(data["sgAccountList"][i]["isAvailable"]!=1){
					htmlStr += '<td>';
					htmlStr += '<img src="../img/again_2.png" title="默认账户" class="cursor_jt"/>&nbsp;&nbsp;&nbsp;';
					htmlStr += '<img src="../img/relieve_2.png" title="解除绑定" class="cursor_jt"/>&nbsp;&nbsp;&nbsp;';
					htmlStr += '<img src="../img/binding.png" title="重新绑定" onclick=$ddf_bank.rebindbanks("'+data["sgAccountList"][i]["accountId"]+'") /> &nbsp;&nbsp;&nbsp;';
					htmlStr += ' <a href=javascript:$ddf_bank.isDeleteBank("'+data["sgAccountList"][i]["accountId"]+'")>删除</a> ';
					htmlStr += '</td>';
				}
				//htmlStr +='<td>操作</td>';
				htmlStr += '</tr> ';

			}

			$("#queryBankList").html(htmlStr);
			
			$('#footPageDiv0').ddf_pagination(data["pageSize"],data["pageNumber"],data["totalCount"],data["totalPage"],{  
				 
				 changePageCallback:function(pageSize,page){  
					 getBankList(page,pageSize);

				 },
				 changePageSizeCallBack:function(pageSize){
					 getBankList(1,pageSize);
		     	 
				 } 
		     }); 

		} else {

			base.tips_error(data["message"]);
		}

		base.cancelLoading();
	}
	
	/**
	 * 查询银行列表和证件类型列表
	 */
	function getBanksParams(){
		var params={
				"page.pageNumber":1,
				"page.pageSize":10000
		        };
		eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.getBanksParams,params));
			
			getBanksParamsCallBack(data);
			
		}))().start();
		
	}

	/**
	 * 查询银行列表和证件类型列表_回调函数
	 */
	function getBanksParamsCallBack(data){
		
		var htmlStr="";
		
		for(var i=0;i<data["banksListData"].length;i++){
			
			//htmlStr+='<li><a href="'+data["banksListData"][i]["bankNumber"]+'">'+data["banksListData"][i]["bankName"]+'</a></li>';
			if(i==0)
				bankId=data["banksListData"][i]["bankId"];
			
			htmlStr += '<option value="'+data["banksListData"][i]["bankId"]+'" >'+data["banksListData"][i]["bankName"]+data["banksListData"][i]["bankId"]+'</option>';

		}
		$("#select-bank-card").html(htmlStr);
		
		base.setSelectStyle();
		
		$("#select-bank-card").change(function(){ 
			
				setBankId($(this).children('option:selected').val());
			
		});
		
		
	}
	
	/**
     * 删除
     */
    exports.isDeleteBank = function(_accountId){
    	var title="删除提示";
		var info="确定要删除吗？";
		var href="####";
		var btnleft="确认";
		var btnright="取消";
		var noplayer=
			'<div id="id2" class="modal">' +
				 '<div class="modal-header">' +
					 '<button class="close over" type="button">×</button>' +
					 '<h3>'+title+'</h3>' +
				 '</div>' +
				 '<div class="modal-body">'+
					 '<p>'+info+'</p>'+
				 '</div>'+
				 '<div class="modal-footer"> <button class="btn btn-primary" onClick=$ddf_bank.deleteBank("'+_accountId+'")>'+btnleft+'</button> <button class="btn over" onClick=$ddf_bank.closeShow2()>'+btnright+'</button> </div>'+
			'</div>';
		$(noplayer).appendTo("body");
		$("<div class='modal-backdrop in'></div>").appendTo("body");
		$("#id2").find(".over").click(function(){
			$("#id2").remove();	
			$("body .modal-backdrop").remove();	
		});
    };
    exports.closeShow2 = function(){
    	$("#id2").remove();	
    	$("body .modal-backdrop").remove();	
    }
    
    /**
     * 删除
     */
    exports.deleteBank = function(_accountId){
    	$ddf_bank.closeShow2();
    	var params={
    			"accountId":_accountId,
    	        };
    	
    	base.showLoading();
    	
    	eval(Wind.compile("async",function(){
    		
    		var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.deleteBank,params));
    		
    		deleteBankCallBack(data);
    		
    	}))().start();
    	
    	
    };
    /**
     * 删除_回调函数
     * @param data
     */
    function deleteBankCallBack(data){
    	
    	base.cancelLoading();
    	if(data["code"]==1){
    		base.tips("删除成功");
    		getBankList(1,pageSize);
    	}else{
    		
    		base.tips_error(data["message"])
    	}
    	
    	
    }
	
	
	/**
	 * 选择银行卡
	 */

	var bankId="";

	function setBankId(id){
		
		bankId=id;
			
	}

	/**
	 * 绑定银行卡
	 */
	function openBindBankCard(){
      
		history.addHis(this,arguments);//增加历史
		var htmlStr="";
		
		htmlStr += '<div id="content-header"><div id="breadcrumb"> <a href=javascript:load("'+ddf.index.index_js+'") title="返回首页" class="tip-bottom"><i class="icon-home"></i> 首页</a><a href="javascript:$ddf_withdraw.showDiv("content0")>银行帐号管理</a><a href="javascript:void(0)" class="current">银行卡绑定</a></div></div>';
		htmlStr += '<div class="container-fluid">';
		htmlStr += '<div class="row-fluid">';
		htmlStr += '<div class="span12">';
		htmlStr += '<div id="alert-tips3" ></div>';
		
		htmlStr += '<div class="widget-box">';
		htmlStr += '<div class="widget-title"> <span class="icon"><i class="icon-th"></i></span>';
		htmlStr += '<h5>绑定银行卡</h5>';
		htmlStr += '</div>';
		htmlStr += '<div class="widget-content nopadding">';
		htmlStr += '<form class="form-horizontal">	   ';
		
		htmlStr += '<div class="control-group" id="control-group-bankId" >';
		htmlStr += '<label class="control-label">银行卡开户行：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input class="span4 alert_w"  id="input-bankCard" type="text" value="请选择银行卡开户行" readonly onclick="$ddf_bank.openBankCardDialog()" />';
		htmlStr += '</div>';
		htmlStr += '</div>';
		/*
		htmlStr += '<div class="control-group">';
		htmlStr += '<label class="control-label">账户类型：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<div class="btn-group"><button data-toggle="dropdown" class="btn dropdown-toggle" ><span id="account_type_name">银行卡</span>&nbsp;&nbsp;<span class="caret"></span></button><ul class="dropdown-menu">';
		htmlStr += '<li><a href=javascript:$ddf_withdraw.setAccountType("00","银行卡")>银行卡</a></li>';
		htmlStr += '<li><a href=javascript:$ddf_withdraw.setAccountType("01","银行存折")>银行存折</a></li>';
		htmlStr += '</ul></div> ';
		htmlStr += '</div>    ';
		htmlStr += '</div>';
		*/
		htmlStr += '<div class="control-group" id="control-group-bankNumber">';
		htmlStr += '<label class="control-label">银行卡号：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input class="span4" type="text" id="input-bankNumber" value="">';
		htmlStr += '</div>              ';
		htmlStr += '</div>';

		htmlStr += '<div class="control-group" id="control-group-accountName">';
		htmlStr += '<label class="control-label">持卡人姓名：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input class="span4" type="text" id="input-accountName" value="">';
		htmlStr += '</div>              ';
		htmlStr += '</div>';
		/*
		htmlStr += '<div class="control-group">';
		htmlStr += '<label class="control-label">证件类型：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<div class="btn-group">';
		htmlStr += '<button data-toggle="dropdown" class="btn dropdown-toggle" ><span id="card_type_name">身份证</span>&nbsp;&nbsp;<span class="caret"></span></button>';
		htmlStr += '<ul class="dropdown-menu">';
		htmlStr += '<li><a href=javascript:$ddf_withdraw.setCardType(1,"身份证")>身份证</a></li>';
		htmlStr += '<li><a href=javascript:$ddf_withdraw.setCardType(2,"军人证")>军人证</a></li>';
		htmlStr += '<li><a href=javascript:$ddf_withdraw.setCardType(3,"户口本")>户口本</a></li>';
		htmlStr += '</ul>';
		htmlStr += '</div>';
		htmlStr += '</div> ';
		htmlStr += '</div>';
		htmlStr += '<div class="control-group" id="control-group-identity">';
		htmlStr += '<label class="control-label">证件号码：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input class="span4" type="text" id="input-identity" value="">';
		htmlStr += '</div>       ';
		htmlStr += '</div>';
		
		htmlStr += '<div class="control-group" id="control-group-mobile">';
		htmlStr += '<label class="control-label">手机号码：</label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input class="span4" type="text" id="input-mobile">       ';
		htmlStr += '</div>                    ';
		htmlStr += '</div>';
		*/
		htmlStr += '<div class="control-group" >';
		htmlStr += '<label class="control-label"></label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input style="position: relative; top: 3px; z-index: 50;" id="defaultAcountCB" type="checkbox" value="true" checked="checked" onClick="$ddf_withdraw.setDefaultAcount()" />设为默认结算账户';
		htmlStr += '</div>             ';
		htmlStr += '</div>';
		/*
		htmlStr += '<div class="control-group" >';
		htmlStr += '<label class="control-label"></label>';
		htmlStr += '<div class="controls">';
		htmlStr += '<input style="position: relative; top: 3px; z-index: 50;"name="redisabledCB" id="redisabledCB" type="checkbox"onclick="$ddf_withdraw.redisabled()" onChange="$ddf_withdraw.redisabled()" /> 同意&nbsp;&nbsp;快捷支付服务协议&nbsp;&nbsp;，下次可凭卡号后4位快速付款';
		htmlStr += '</div>                  ';
		htmlStr += '</div>';
		*/
		
		htmlStr += '<div class="form-actions">';
		htmlStr += '<button class="btn btn-primary" id="btnBindBankCard" type="button" onclick="$ddf_bank.bindBankCard()" >绑定</button> ';
		htmlStr += '<button class="btn btn-info" type="button" onClick=$ddf_bank.showDiv("content0")>返回</button>  ';
		htmlStr += '</div>  ';
		htmlStr += '</form>';
		htmlStr += '</div>';
		htmlStr += '</div>  ';
		
		
		htmlStr += '</div>  ';
		htmlStr += '</div>';
		htmlStr += '</div> ';
		htmlStr += '</div> ';

		showDiv("content3");

		$("#content3").html(htmlStr);
		
		setRadioStyle();
		
		
		$("#input-bankNumber").change(function() {
			var bankNumber=$("#input-bankNumber").val();

			if(isNull(bankNumber)){
				base.clearErrorMessage("control-group-bankNumber");
				base.addErrorMessage("control-group-bankNumber","input-bankNumber","卡号非法");
				return;
			}else if(!isNumber(bankNumber)){
				base.clearErrorMessage("control-group-bankNumber");
				base.addErrorMessage("control-group-bankNumber","input-bankNumber","卡号必须全为数字");
				return;
			}else if(!isLength(bankNumber,8)){
				base.clearErrorMessage("control-group-bankNumber");
				base.addErrorMessage("control-group-bankNumber","input-bankNumber","卡号长度必须大于8位");
				return;
			}else{
				base.clearErrorMessage("control-group-bankNumber");
			}

		});
		
		$("#input-accountName").change(function() {

			var accountName=$("#input-accountName").val();

			if(isNull(accountName)){
				addErrorMessage("control-group-accountName","input-accountName","持卡人姓名非法");
			}else{
				clearErrorMessage("control-group-accountName");
			}

		});
	}

	/**
	 * 设置是否选择默认
	 */
	var defaultAcount="true";
	function setDefaultAcount() {
		
		if ($("#defaultAcountCB").is(":checked")) {
			defaultAcount="true";
		}else{
			defaultAcount="false";
		}
	}

	
	/**
	 * 设置单选框样式
	 */
	function setRadioStyle(){
		
		$('input[type=checkbox],input[type=radio],input[type=file]').uniform();
		
	}
	
	/**
	 * 是否已读条款
	 */
	function redisabled() {
		if ($("#redisabledCB").is(":checked")) {
			$("#btnBindBankCard").attr("disabled", false);
		} else {
			$("#btnBindBankCard").attr("disabled", true);
		}
	}
	
	


	/**
	 * 获取身份类型
	 */
	function getCardId(){
		eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.getCardType,""));
			
			getBanksCardTypeCallBack(data);
			
		}))().start();
	}

	/**
	 * 获取身份类型的回调函数
	 * @param data
	 */
	function getBanksCardTypeCallBack(data){
		
		htmlStr="";
		
		for(var i=0;i<data["resultIdCardsList"].length;i++){
			
			htmlStr+='<li><a href=javascript:setCardType("'+data["resultIdCardsList"][i]["idCardNumber"]+'","'+data["resultIdCardsList"][i]["idCardName"]+'")>'+data["resultIdCardsList"][i]["idCardName"]+'</a></li>';
			
		}

		$("#select-id-card").html(htmlStr);
	}

	/**
	 * 选择证件类型
	 */
	var identifyTypeId="1";

	function setCardType(type,name){
		identifyTypeId=type;
		$("#card_type_name").html(name);
		
	}
	
	var accountType = "00";
	/**
	 * 选择账户类型
	 */
	function setAccountType(type,name){
		accountType = type;
		$("#account_type_name").html(name);
	}

	/**
	 * 银行卡绑定
	 */
	function bindBankCard(){
		
		var bankNumber=$("#input-bankNumber").val();
		var accountName=$("#input-accountName").val();
//		var identity=$("#input-identity").val();
//		var mobile=$("#input-mobile").val();
		
		
//		if(bankId=="-1" || bankId==""){
//			addErrorMessage("control-group-bankId","input-bankCard","请选择银行");
//			return;
//		}
		
		
		if(isNull(bankNumber)){
			base.clearErrorMessage("control-group-bankNumber");
			base.addErrorMessage("control-group-bankNumber","input-bankNumber","卡号非法");
			return;
		}else if(!isNumber(bankNumber)){
			base.clearErrorMessage("control-group-bankNumber");
			base.addErrorMessage("control-group-bankNumber","input-bankNumber","卡号必须全为数字");
			return;
		}else if(!isLength(bankNumber,8)){
			base.clearErrorMessage("control-group-bankNumber");
			base.addErrorMessage("control-group-bankNumber","input-bankNumber","卡号长度必须大于8位");
			return;
		}
		
		if(isNull(accountName)){
			addErrorMessage("control-group-accountName","input-accountName","持卡人姓名非法");
			return;
		}
		
//		if(isNull(identity)){
//			addErrorMessage("control-group-identity","input-identity","证件号码不能为空");
//			return;
//		}else if(isLength(identity,50)){
//			addErrorMessage("control-group-identity","input-identity","证件号码长度不能大于50字节");
//			return;
//		}else{
//			if(identifyTypeId==1){
//				if(!isIdCard(identity)){
//					addErrorMessage("control-group-identity","input-identity","身份证号非法");
//					return;
//				}else{
//					clearErrorMessage("control-group-identity");
//				}
//			}else if(identifyTypeId==2){
//				if(!isJgCard(identity)){
//					addErrorMessage("control-group-identity","input-identity","军人证号非法");
//					return;
//				}else{
//					clearErrorMessage("control-group-identity");
//				}
//			}else{
//				clearErrorMessage("control-group-identity");
//			}
//		}
		
//		if(!isNull(mobile) && !isMobile(mobile)){
//			addErrorMessage("control-group-mobile","input-mobile","手机号码非法");
//			return;
//		}
		
		
		var params={
				
				"sgAccount.accountName":accountName,
				"sgAccount.bankId":bankId,
				"sgAccount.bankNumber":bankNumber,
				"sgAccount.identifyTypeId":identifyTypeId,
//				"sgAccount.identity":identity,
//				"sgAccount.mobile":mobile,
				"defaultaccount":defaultAcount,
				"sgAccount.accountType" : accountType 
		        };
		
		base.showLoading();

		eval(Wind.compile("async",function(){
			
			var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.getBindBankCard,params));
			
			bindBankCardCallBack(data);
			
		}))().start();
	}

	/**
	 * 绑定银行卡_回调函数
	 * @param data
	 */
	var bingBanFlag = false;
	function bindBankCardCallBack(data){
		base.cancelLoading();
		if(data["code"]==1){
			showDiv("content0");
			bingBanFlag=true;
			defaultAcount = "false";
			getBankList(1,pageSize);
		}else{
			 base.tips_error(data["message"]);
		}
		
		
	}
	
	
	/**
	 *	设为默认账户 
	 */
	function setdefaultaccount(accountId,bankNumber) {
		if (confirm("您只能有一个默认结算账户,确认要将结算账户变更为" + bankNumber + "吗?")) {
			var params={
					
					"sgAccount.accountId":accountId
					
			        };
			
			base.showLoading();
				
			eval(Wind.compile("async",function(){
				
				var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.setDefaultAccounts,params));
				
				setdefaultaccountCallBack(data);
				
			}))().start();
		
		}
		
	}
	/**
	 * 设为默认账户_回调函数
	 */
	function setdefaultaccountCallBack(data){
		base.cancelLoading();
		if(data["code"]==1){
			base.tips("默认账户成功！");
			getBankList(1,pageSize);
			
		}else{
			 base.tips_error(data["message"]);
		}
		
		
	}

	
	/**
	 *	银行卡解绑 
	 */
	function unbindbanks(accountId,bankNumber) {
		if (confirm("确定解除账户  "+bankNumber+" 的绑定记录?")) {

			var params={
					
					"sgAccount.accountId":accountId
					
			        };
			
			base.showLoading();
				
			eval(Wind.compile("async",function(){
				
				var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.unBindBanks,params));
				
				unbindbanksCardCallBack(data);
				
			}))().start();
		}
	}
	/**
	 * 解绑银行卡_回调函数
	 */
	function unbindbanksCardCallBack(data){
		base.cancelLoading();
		if(data["code"]==1){
			getBankList(1,pageSize);
			base.tips("银行卡解绑成功！");
		}else{
			 base.tips_error(data["message"]);
		}
		
		
	}


	/*
	 * 重新绑定银行卡
	 */
	function rebindbanks(accountId) {
		
		if (accountId == "") {
			base.tips(data["账户ID不能为空!"]);
		} else {
			var params={
					
					"sgAccount.accountId":accountId
					
			        };
			
			base.showLoading();
				
			eval(Wind.compile("async",function(){
				
				var data = $await(wind_async.DDF_AsyncRequest("POST",ddf.bank.reBindBanks,params));
				
				rebindbanksCardCallBack(data);
				
			}))().start();
		}

	}

	/**
	 * 重新绑定银行卡_回调函数
	 */
	function rebindbanksCardCallBack(data){
		base.cancelLoading();
		if(data["code"]==1){
			base.tips("重新绑定银行卡成功！");
			getBankList(1,pageSize);
		}else{
			 base.tips_error(data["message"]);
		}
		
		
	}


	/**
	 * 打开银行列表
	 */
	exports.openBankCardDialog=function(){

		dialog.ddf_dialog_bank($("#input-bankCard"),function(id,name){  
			
			$("#input-bankCard").val(name);
			
			setBankId(id);

			
	    });
		
	};


	
	
	/**
	 * 显示DIV
	 */
	function showDiv(block){
		
		$("#content > div").hide();
		
		if($("#"+block).length<=0){
			
			$("#content").append('<div id="'+block+'"></div>'); 
			
		}else{
			
			$("#"+block).show();
		}
		
		if(block=="content0"){
			shopTypeId="";
		}
		

		
	}

	/**
	 * 对外提供访问的方法
	 */

	exports.openBindBankCard = openBindBankCard; //打开绑定银行卡的界面
	exports.bindBankCard = bindBankCard ;//银行卡绑定
	exports.setDefaultAcount = setDefaultAcount; //设置为默认
	window.$ddf_getBankList = getBankList; //獲取银行列表
	exports.setRadioStyle = setRadioStyle ; //设置单选按钮样式
	exports.redisabled = redisabled; //是否已读协议
	exports.setdefaultaccount = setdefaultaccount; //设置默认账户
    exports.unbindbanks = unbindbanks; //解除绑定
    exports.rebindbanks = rebindbanks; //重新绑定
 	exports.setAccountType = setAccountType; //获取卡片ID号
	exports.setCardType = setCardType ; //设置证件类型
	exports.setBankId = setBankId; // 设置银行代码
	exports.getBanksParamsCallBack=getBanksParamsCallBack;
	exports.showDiv = showDiv; 
});
